package com.dstz.sys.core.manager.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dstz.base.manager.impl.BaseManager;
import com.dstz.sys.core.dao.SysScheduleJobDao;
import com.dstz.sys.core.manager.SysScheduleJobManager;
import com.dstz.sys.core.model.SysScheduleJob;

/**
 * 系统执行计划通过处理
 *
 * @author didi
 */
@Service("sysScheduleJobManager")
public class SysScheduleJobManagerImpl extends BaseManager<String, SysScheduleJob> implements SysScheduleJobManager {

    @Resource(name = "sysScheduleJobDao")
    private SysScheduleJobDao sysScheduleJobDao;

	@Override
	public boolean enableSysScheduleJob(String id) {
		SysScheduleJob sysScheduleJob = new SysScheduleJob();
		sysScheduleJob.setId(id);
		sysScheduleJob.setRunningState(SysScheduleJob.ENABLE);
		int update = sysScheduleJobDao.updateByPrimaryKeySelective(sysScheduleJob);
		return update>0;
	}

	@Override
	public boolean disableSysScheduleJob(String id) {
		SysScheduleJob sysScheduleJob = new SysScheduleJob();
		sysScheduleJob.setId(id);
		sysScheduleJob.setRunningState(SysScheduleJob.DISABLE);
		int update = sysScheduleJobDao.updateByPrimaryKeySelective(sysScheduleJob);
		return update>0;
	}

	@Override
	public boolean exists(String jobName, String jobGroup) {
		return sysScheduleJobDao.exists(jobName, jobGroup);
	}
 
}
